#ifndef __BASE_STRING_UTIL_H_
#define __BASE_STRING_UTIL_H_

#include <vector>
#include <string>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <sstream>

namespace BASE{
	enum NumType{
		NUM_INVALID = -1,
		NUM_NEG,
		NUM_INT,
		NUM_OCT,
		NUM_HEX,
		NUM_DOUBLE,
	};

	typedef std::vector<std::string> Strings;

	std::string lowerstr(const std::string & source);

	std::string upperstr(const std::string & source);

	Strings stringsplit(const std::string & source, const std::string & split);

	void initMatch(uint8_t chmap[256], int chmapSize, const std::string & match);

	std::string trim(std::string & source, const std::string & match = " \t\r\n");

	std::string ltrim(std::string & source, const std::string & match = " \t\r\n");

	std::string rtrim(std::string & source, const std::string & match = " \t\r\n");

	template<typename T>
	std::string toString(T t){
		std::ostringstream ss;
		ss << t;
		return ss.str();
	}
	
	NumType getNumType(const std::string & val);

	bool getBool(const std::string & val, bool defaultVal = false);

	int16_t getShort(const std::string & val);

	int32_t getInt(const std::string & val);

	int64_t getLong(const std::string & val);

	double getDouble(const std::string & val);
}
#endif
